package schedule;

import java.util.Timer;
import java.util.TimerTask;

import cpu.CPU;

/**
 * The system timer, used for timed interrupts.
 * @author kyle
 * @version 3.9.13
 *
 */
public class SystemTimer
{
	/**
	 * The timer to cause an interrupt
	 */
	private Timer my_timer;
	

	
	Integer s;
	
	/**
	 * Creates a timer task with a timer that cuases an interrupt.
	 */
	public SystemTimer(Integer t)
	{
		my_timer = new Timer();
		s = t;
	}

	/**
	 * Creates a timed task ran by the timer.
	 * @author kyle
	 * @version 3.9.13
	 *
	 */
	private class InterruptTask extends TimerTask
	{

		@Override
		public void run() {
			CPU.context_switch = 1;
		}
		
	}
	
	public void setTimer()
	{
		my_timer.schedule(new InterruptTask(), 1, 1);
	}
	

}
